<template>
    <div class="wage-calculator">
        <h1>牛马收益</h1>
        <div class="content">
            <div class="info">
                <div class="info-header">
                    <div class="rol"></div>
                    <div class="line"></div>
                </div>
                <h2>计算公式：</h2>
                <p>工作性价比 = 平均日薪综合环境系数 / 35 * (工作市场+通勤时长-0.5X横鱼时长) * X学历指数</p>
                <h2>最终结果说明：</h2>
                <p>&lt; 0.8 就不幸福<br />> 1.5 说明工作已经很爽了<br />> 2.0 代表有份神仙工作</p>
                <h2>系数说明：</h2>
                <p>平均日薪 = 月薪 / 工作天数<br />综合环境系数 = 工作环境系数 * X异性环境系数 * X同事环境系数<br />各类时间：<br />工作时长 = 下班时间 -
                    上班时间<br />通勤时长 = 上班通勤 + 下班通勤<br />横鱼时长 = 不干活时长 + 吃饭时长 + 午休时长</p>
            </div>
            <div class="calculator-container">
                <div class="calculator">
                    <div class="header">工作性价比计算器</div>
                    <div class="input-group">
                        <label>每天通勤时间：</label>
                        <input v-model="commuteTime" placeholder="请输入您每天上下班的通勤时间" />
                    </div>
                    <div class="input-group">
                        <label>每天摸鱼时长：</label>
                        <input v-model="leisureTime" placeholder="请输入您的摸鱼时长（指不在工作的时长+吃饭时长+午休时长）" />
                    </div>
                    <div class="input-group">
                        <label>您的学历：</label>
                        <select v-model="education">
                            <option selected disabled="disabled" label=" --请选择--">
                            </option>
                                <option value="1">专科及以下学历</option>
                                <option value="2">普通本科学历</option>
                                <option value="3">211/985本科学历</option>
                                <option value="4">普通硕士学历</option>
                                <option value="5">211/985硕士学历</option>
                                <option value="6">普通博士学历</option>
                                <option value="7">211/985博士学历</option>
                        </select>
                    </div>
                    <button @click="calculateRealTimeWage">下一步</button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                commuteTime: '',
                leisureTime: '',
                education: ''
            };
        },
        methods: {
            calculateRealTimeWage() {
                const { commuteTime, leisureTime, education } = this;
                if (!commuteTime || !leisureTime || !education) {
                    window.alert('检测到输入数据有空值，请填写完整后再提交。');
                    return;
                }
                if (isNaN(commuteTime) || parseFloat(commuteTime) < 0 || parseFloat(commuteTime) > 24) {
                    window.alert('每天通勤时间必须是 0 - 24 之间的数字。');
                    return;
                }
                if (isNaN(leisureTime) || parseFloat(leisureTime) < 0 || parseFloat(leisureTime) > 24) {
                    window.alert('每天摸鱼时长必须是 0 - 24 之间的数字。');
                    return;
                }
                this.$router.push({
                    path: '/priceViewInputPage3',
                    query: {
                        ...this.$route.query,
                        commuteTime: this.commuteTime,
                        leisureTime: this.leisureTime,
                        education: this.education
                    }
                });
            }
        }
    };
</script>

<style scoped>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    .content {
        display: flex;
        justify-content: center;
        align-items: flex-start;
        width: 100vw;
        height: 100vh;
    }

    .wage-calculator {
        width: 100vw;
        height: 100vh;
        background-color: #888;
        padding: 20px;
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    h1 {
        color: white;
        width: 548px;
        height: 157px;
        font-size: 100px;
        font-family: STXinwei;
    }

    .calculator-container {
        width: 50%;
        height: 80%;
        background-color: white;
        border-radius: 10px;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin-left: 20px;
    }

    .info {
        width: 30%;
        height: 80%;
        background-color: white;
        border-radius: 10px;
        padding: 20px;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
        font-size: 20px;
        text-align: left;
    }

    .info-header {
        width: 100%;
        height: 50px;
    }

    .rol {
        width: 50px;
        height: 50px;
        background-color: #f0c040;
        border-radius: 50%;
    }

    .line {
        border-bottom: 5px dashed black;
    }

    .calculator {
        width: 100%;
        height: 100%;
        background-color: #f9f9f9;
        padding: 20px;
        border-radius: 10px;
    }

    .header {
        width: 100%;
        /* height: 40%; */
        background-color: #f0c040;
        color: white;
        padding: 10px;
        border-radius: 10px;
        font-weight: bold;
        margin-bottom: 20px;
    }

    .input-group {
        width: 100%;
        margin-bottom: 15px;
        text-align: left;
        font-size: 30px;
    }

    input {
        width: 100%;
        height: 80px;
    }

    label {
        display: block;
        margin-bottom: 5px;
        color: #f0c040;
    }

    input, select{
        width: 100%;
        padding: 8px;
        border: 1px solid #ccc;
        border-radius: 4px;
    }

    button {
        background-color: #f0c040;
        color: white;
        padding: 10px 20px;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }
</style>